Replication Materials for "Identity, Information, and Voting:

Lessons on African Elections from a Survey Experiment"
===========================================

This folder contains all datasets and code required to replicate the results in the paper "Identity, Information, and Voting:

Lessons on African Elections from a Survey Experiment" 

Folder Structure
----------------

- `data/`  
    Contains all raw and processed datasets used in the analysis.

- `code/`  
    Contains scripts for data cleaning, analysis, and figure/table generation.

- `output/`  
    Contains generated results, tables, and figures.

File Descriptions
-----------------

### data/
- `EVMB_KE.dta`  
    Original experimental dataset for Kenya used as input for the analysis.

- `EVMB_LI.dta`  
    Original experimental dataset for Lilongwe used as input for the analysis.

- `EVMB_LU.dta`  
    Original experimental dataset for Lusaka used as input for the analysis.

- `EVMB_MB.dta`  
    Original experimental dataset for Malawi Border used as input for the analysis.

- `EVMB_ZB.dta`  
    Original experimental dataset for Zambia Border used as input for the analysis.

- `CTRL_KE.dta`  
    Original control variables dataset for Kenya used as input for the analysis.

- `CTRL_LI.dta`  
    Original control variables dataset for Lilongwe used as input for the analysis.

- `CTRL_LU.dta`  
    Original control variables dataset for Lusaka used as input for the analysis.

- `CTRL_MB.dta`  
    Original control variables dataset for Malawi Border used as input for the analysis.

- `CTRL_ZB.dta`  
    Original control variables dataset for Zambia Border used as input for the analysis.

- `EVMB_CTRL.dta`  
    Cleaned, merged, and transformed dataset used in the analysis.

### code/
- `Mediation Power Analysis.R`  
    Script to perform a simulation-based power analysis for the eliminated effect. Outputs `PowerAnalysis_EliminatedEffect.png`.

- `mediation_preparation.do`  
    Script to clean, merge, and transform data for analyis. Produces the dataset `EVMB_CTRL.dta`.

- `mediation_analysis.do`
    Script to perform all analyses in the paper including robustness checks found in the appendix.

- `Interation_Plots.R`
    Script to create the interaction plot of the eliminated effect.

- `Demographics_Table_Statistics.do`
Script to calculate the entries of the demographics table and the distribution of experimental treatments.


### output/
- `PowerAnalysis_EliminatedEffect.png`  
    Graphic representation of the sample sizes need to detect eliminated effects of different magnitudes.

- `EliminatedEffect_Interaction.png`
    Graphic representation of interaction between being co-ethnic with the candidate and each mediator on the vote outome


Dependencies and Workflow
-------------------------

1. **Data Cleaning:**  
     Run `code/mediation_preparation.do` to process the `data/EVMB_##.dta` and `data/CTRL_##.dta` files into `data/EVMB_CTRL.dta`.

2. **Data Summary:**
    Run `Demographics_Table_Statistics.do` using `data/EVMB_CTRL.dta` to get the values for Table 1 and Table 4.

2. **Power Analysis:**  
    Run `code/Mediation Power Analysis.R` to generate `output/PowerAnalysis_EliminatedEffect.png`.

3. **Analysis:**
    Run `code/mediation_analysis.do` using `data/EVMB_CTRL.dta`.

4. **Figures:**  
     Run `code/Interation_Plots.R` to create the figure `output/EliminatedEffect_Interaction.png` from the analysis results.

Software Requirements
---------------------
- R packages: InteractionPower, ggplot2, ggformula, haven, ggpubr, interactions, grid. (see code scripts for details)

Contact
-------

For questions, contact Erica Ann Metheney at data@gld.gu.se.